package actions;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

public class PrintAction implements Action{
	
	private String _output;
	
	public PrintAction(){
		_output = null;
	}
	
	public void doAction(File file, ArrayList<File> files){
		_output = "";
		if (file.canRead()) 
			add("r");
		else
			add("-");
		if (file.canWrite()) 
			add("w");
		else
			add("-");
		if (file.canExecute()) 
			add("x ");
		else
			add("- ");
		try {
			String path = file.getCanonicalPath();
			System.out.println(_output + file.length() + " " + path);
		}
		catch (IOException e){
			return;
		}
	}
	
	private void add(String toAdd){
		_output = _output.concat(toAdd);
	}
	
	//TESTER
	public static void main (String args[]){
		File file = new File ("C:\\Intel\\cmd.txt");
		file.setExecutable(false);
		PrintAction h = new PrintAction();
		
		h.doAction(file);
	}

}
